package com.application.Activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

import com.application.Controller.ActivityController;
import com.application.Network.Protocol;
import com.application.outdoor.InvoikeServices.HeThongInvoike;

public class od_MoiVaoNhomActivity extends Activity {
	Button btnDongY, btnTuChoi;
	TextView txtNoiDung;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_moi_vao_nhom);        
        ActivityController.arrActivity.add(this);
        Intent intent= getIntent();
        btnDongY=(Button)findViewById(R.id.btnDongY);
        btnTuChoi=(Button)findViewById(R.id.btnTuChoi);
        txtNoiDung=(TextView)findViewById(R.id.txtNoiDung);
        if(intent!=null){
        	String nguoiGui=intent.getStringExtra(Protocol.NGUOI_DUNG);
        	String noiDung=intent.getStringExtra(Protocol.NOI_DUNG);
        	final int idTinNhan=Integer.parseInt(intent.getStringExtra(Protocol.ID));
        	
        	String []m=noiDung.split(";");
        	final int idNhom=Integer.parseInt(m[0]);
        	txtNoiDung.setText(nguoiGui +" mời bạn vào nhóm "+m[1]);
        	btnDongY.setOnClickListener(new OnClickListener() {
				
				@Override
				public void onClick(View v) {
					try {
						new HeThongInvoike().dongYVaoNhom( idNhom,  idTinNhan,  CommonUtilities.nguoiDung.getTenDangNhap());
					} catch (Exception e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
				}
			});
        }
    }
    
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_moi_vao_nhom, menu);
        return true;
    }

    
}
